package com.jsnkj.basic.dialog

import android.app.Activity
import android.app.Dialog
import android.os.Bundle
import android.view.View
import android.widget.TextView
import com.jsnkj.basic.R


/**
 * 文案弹窗
 */
class TextShowDialog(
    var dialogContext: Activity,
    var txtTitle: String,
    var txtContent: String,
    var click: onItemClickListener
) : Dialog(dialogContext), View.OnClickListener {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dialog_text_show)
        setCanceledOnTouchOutside(true)
        setCancelable(false)
        window?.setBackgroundDrawableResource(android.R.color.transparent)
        initView()
    }

    fun initView() {
        val tvTitle: TextView = findViewById(R.id.tv_title)
        tvTitle.text = txtTitle

        val tvContent: TextView = findViewById(R.id.tv_content)
        tvContent.text = txtContent

        val tvConfirm: TextView = findViewById(R.id.tv_confirm)
        tvConfirm.setOnClickListener(this)
    }


    interface onItemClickListener {
        fun txtItemClick()
    }

    override fun onClick(view: View) {
        dismiss()
        when (view.id) {
            R.id.txt_save_image -> {
                click.txtItemClick()
            }
        }
    }
}